package be.donovan.gui.helper.components;

import javax.swing.JFrame;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public abstract class MVCFrame extends JFrame implements ViewI {
	protected Log logger = LogFactory.getLog(this.getClass());
	@SuppressWarnings("unchecked")
	public AbstractController controller;
	
	@SuppressWarnings("unchecked")
	public void setController(AbstractController controller){
		this.controller=controller;
		controller.setView(this);
		controller.cleanup();
	}
	
	/**
	 * Create a afterPropertiesSet() method for Spring. 
	 * Implement it as getController().initData(). 
	 * Adapt the MVC framework module as such
	 */
	public void afterPropertiesSet() throws Exception{
		if(controller==null){
			logger.warn("No controller set");
		}else{
			controller.initListeners();
			controller.initData();
		}
	}

}
